package com.javaee.finalproject.service.impl;

import com.javaee.finalproject.entity.Student;
import com.javaee.finalproject.mapper.StudentMapper;
import com.javaee.finalproject.service.StudentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author testjava
 * @since 2020-06-13
 */
@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student> implements StudentService {

    @Override
    public String getPassword(String account) {
        Student student = baseMapper.selectById(account);
        String password = student.getPassword();
        return password;
    }

    @Override
    public List<Student> get_all_student() {
        List<Student> studentList = baseMapper.selectList(null);
        return studentList;
    }

    @Override
    public void add_student(String student_id, String stu_name, String stu_age, String stu_tel) {
        Integer count = baseMapper.selectCount(null);
        Date time=new Date();
        Student student = new Student();
        student.setSid(String.valueOf(count+1));
        student.setPassword("12345");
        Integer sage = Integer.valueOf(stu_age);
        student.setSage(sage);
        student.setSname(stu_name);
        student.setStel(stu_tel);
        baseMapper.insert(student);
    }
}
